package com.chenfan.mcn.extension.excel;

import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import lombok.Getter;
import org.apache.commons.collections4.CollectionUtils;
import java.util.*;

/**
 * 多Sheet的Excel导出模板
 *
 * @author wulg
 * @date 2021-12-28
 **/
@Getter
public final class DynamicExcel {

    private String sheetName;

    private List<ExcelExportEntity> entityList;

    private Class<?> entityClass;

    private List<Map<String, Object>> dataSet;

    public DynamicExcel(String sheetName, List<ExcelExportEntity> entityList, List<Map<String, Object>> dataSet) {
        this.sheetName = sheetName;
        this.entityList = entityList;
        if(CollectionUtils.isEmpty(dataSet)) {
            this.dataSet = new ArrayList<>(0);
        } else {
            this.dataSet = dataSet;
        }
    }

    public DynamicExcel(String sheetName, Class<?> entityClass, List<Map<String, Object>> dataSet) {
        this.sheetName = sheetName;
        this.entityClass = entityClass;
        if(CollectionUtils.isEmpty(dataSet)) {
            this.dataSet = new ArrayList<>(0);
        } else {
            this.dataSet = dataSet;
        }
    }
}
